package com.zzh.structuredeployment.activity

import android.graphics.PointF
import android.os.Bundle
import android.util.Log
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.zzh.bridge.page.PageApp
import com.zzh.bridge_annotation.RouteTag
import com.zzh.custom.ShapeDrawView
import com.zzh.structuredeployment.R
import kotlinx.android.synthetic.main.activity_twelve.*

@RouteTag(PageApp.TWELVE)
class TwelveActivity : AppCompatActivity() {

    private val mShapeDrawView by lazy {
        findViewById<ShapeDrawView>(R.id.mShapeDrawView)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_twelve)
        findViewById<Button>(R.id.top).setOnClickListener {
            val pointF = mShapeDrawView.centerPointF
            mShapeDrawView.updateCenter(pointF.x, pointF.y - 10)
        }

        findViewById<Button>(R.id.bottom).setOnClickListener {
            val pointF = mShapeDrawView.centerPointF
            mShapeDrawView.updateCenter(pointF.x, pointF.y + 10)
        }

        findViewById<Button>(R.id.left).setOnClickListener {
            val pointF = mShapeDrawView.centerPointF
            mShapeDrawView.updateCenter(pointF.x - 10, pointF.y)
        }

        findViewById<Button>(R.id.right).setOnClickListener {
            val pointF = mShapeDrawView.centerPointF
            mShapeDrawView.updateCenter(pointF.x + 10, pointF.y)
        }
        findViewById<Button>(R.id.big).setOnClickListener {
            val zoom = mShapeDrawView.zoom
            mShapeDrawView.updateZoom(zoom + 1)
        }
        findViewById<Button>(R.id.small).setOnClickListener {
            val zoom = mShapeDrawView.zoom
            mShapeDrawView.updateZoom(zoom - 1)
        }

        back.setOnClickListener {
            if (mShapeDrawView.isPrevious) {
                mShapeDrawView.previous()
                return@setOnClickListener
            }
            finish()
        }

    }


}